<%@page import="com.lzl.dao.Adminloginimpl"%>
<%@page import="com.lzl.dao.Adminlogin"%>
<%@page import="com.lzl.entity.Admin"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String username=request.getParameter("username");
String password=request.getParameter("password");
String newpwd=request.getParameter("newpwd");
String newpwd1=request.getParameter("newpwd1");

Object password1=session.getAttribute("password");
String password2=String.valueOf(password1);

if(newpwd.equals(newpwd1)&&password.equals(password1))
{
	Adminloginimpl loginuser=new Adminloginimpl();
	Admin user=null;
	user=loginuser.find(username);
	
	user.setPassword(newpwd);
	loginuser.updatepwd(user);
	out.print("<script language='javascript'>alert('修改成功！！请重新登录');window.location.href='leave.jsp';</script>");  
}
else if(!password.equals(password1))
{
	out.print("<script language='javascript'>alert('原密码错误');window.location.href='updatepwd.jsp';</script>");  
	}
else{
	out.print("<script language='javascript'>alert('密码不一致');window.location.href='updatepwd.jsp';</script>");  
}
%>
</body>
</html>